package com.zzk.protect.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zzk.protect.common.CommonResult;
import com.zzk.protect.pojo.Schedule;
import com.zzk.protect.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("/schedule")
public class ScheduleController {
    @Autowired
    private ScheduleService service;

    @GetMapping("/check")
    public CommonResult<List<Schedule>> check(@RequestParam Long doctorId,
                                              @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate date){
        QueryWrapper<Schedule> qw = new QueryWrapper<>();
        qw.eq("doctor_id",doctorId).eq("schedule_date",date).eq("is_deleted", 1);;
        return CommonResult.success(service.list(qw));
    }
}
